<template>
    <el-form ref="form" :model="teacher"  label-width="70px" style="width: 800px">
    <el-form-item label="姓名"  prop="studentname"><br>
    <el-input  v-model="teacher.teachername" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="性别"  prop="sex"><br>
         <el-radio v-model="teacher.sex" disabled style="margin-right:200px" label="男">男</el-radio>
         <el-radio v-model="teacher.sex"  disabled style="margin-right:400px" label="女">女</el-radio>
    </el-form-item>
    <el-form-item label="电话"  prop="tel" ><br>
        <el-input v-model="teacher.tel" :disabled="true"></el-input> 
    </el-form-item>
    <el-form-item label="邮箱"  prop="email"><br>
    <el-row>
        <el-input v-model="teacher.email" :disabled="true"></el-input>
    </el-row>
    </el-form-item>
    <el-form-item label="教学经历"  prop="experience"><br>
        <el-input type="textarea" v-model="teacher.experience" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item label="教学领域"  prop="field"><br>
        <el-input type="textarea" v-model="teacher.field" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item  ><br>
      <el-button type="primary" @click="edit(teacher)">修改信息</el-button>
    </el-form-item>

    <Edit :visible='visible' :title="title" :defaultFormData='defaultFormData' 
    v-if='visible' @close = 'close'/>
    </el-form>
    
</template>

<script>

import {select} from '@/api/modules/teacher_infor'
import {getCookie} from '@/libs/cookie'
import Edit from '../edit/edit_teacher'

export default {
    name:'student_infor',
    components:{Edit},
    data(){
        return{
            teacher:{},
            user:{
                id:''
            },
            loading: false,
            visible: false,
            defaultFormDate:{},
            title:'',
        }
    },
    mounted(){
        let user = JSON.parse(getCookie("user") || '{}');
        this.user.id = user.id
        console.log(user)
        this.getInfor()
    },
    methods:{
        getInfor(filter){
            filter={
                ...filter,
                ...this.user
            },
            select(filter).then(res =>{
           //     console.log(res.data)
              this.teacher = res.data
          })
        },
              handleClose() {
               this.$refs.form.resetFields()
      },
      
      edit(row){
        this.visible = true
        this.title = '修改信息'
        this.defaultFormData = row
      },
      close(val){
        this.visible = false
        this.getInfor()
      },
    }
}
</script>

